var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tm: [],
    loading: false,
    plain: false,
    disabled: false,//按钮一旦点击提交 则不能操作
    activeindex: 0,
    bid:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var usid = wx.getStorageSync('usid');
    if (!usid) {
      wx.reLaunch({
        url: '../../pages/login/login'
      })
      return;
    }
    this.setData({
      bid: options.bid,
      usid: usid
    })
    this.getScdhTmByPid();
  },

  getScdhTmByPid() {
    var that = this;
    var bid = that.data.bid;
    var usid = wx.getStorageSync('usid');
    app.wxget({
      url: 'wscdh/getmyScdhInfo.html',
      data: {
        bid: bid,
        usid: usid
      },
      success: function (res) {
        var datas = res.data;
        that.setData({
          tm: datas
        })
      }
    })
  },

  //下一题
  nexttm() {
    var activeindex = this.data.activeindex;
    var i = parseInt(activeindex) + 1;
    this.setData({
      activeindex: i
    })
  },
  //上一题
  pretm() {
    var activeindex = this.data.activeindex;
    var i = parseInt(activeindex) - 1;
    this.setData({
      activeindex: i
    })
  },

  //查看排行榜
  lookphb() {
    wx.redirectTo({
      url: '../../pages/scdhcg/scdhcg?bid=' + this.data.bid
    })
  }


})